<?php
namespace app\api\controller;

use app\middleware\TokenAuthMiddleware;

class BaseClientController
{

    public function __construct()
    {
    }

    // 定义控制器使用的中间件
    public static array $middleware = [
        TokenAuthMiddleware::class,
    ];

    // 可添加其他基础方法，供子类继承使用
    protected function success($data = [], $message = '操作成功')
    {
        return json([
            'code'    => 200,
            'message' => $message,
            'data'    => $data,
        ]);
    }

    protected function error($message = '操作失败', $code = 500)
    {
        return json([
            'code'    => $code,
            'message' => $message,
        ]);
    }
}
